﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.SoldierArchives.BLL;

public partial class Police_TransferList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindAcceptCount();
        }
    }



    private void BindAcceptCount()
    {
        //具备本级调动权限
        if (Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "400103") || Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "400104"))
        {
        if (string.IsNullOrEmpty(Request["DepartmentID"]))
            return;

        string DepartmentID = Request["DepartmentID"].Substring(0, 4) + "000";

        int Count = TransferSoldier.NeedAcceptedCount(DepartmentID);
        gvTrasferStat.DataSource = TransferSoldier.GetTransfersByWhere(" toUnitID='" + DepartmentID + "' and acceptorID is null and CheckInDate is null", Count, 0);
        gvTrasferStat.DataBind(); 
        }
        else
        {
            Response.Write("<script>alert('没有权限！');history.back(0);</script>");

        }
    }

    public string GetSoldierName(object obj)
    {
        if (obj == null)
            return "";

        Yipusoft.SoldierArchives.BLL.Soldier soldier = new Yipusoft.SoldierArchives.BLL.Soldier();
        if (string.IsNullOrEmpty(obj.ToString()))
            return "";

        Yipusoft.SoldierArchives.Model.SoldierArchiveInfo info = soldier.GetSoldierInfoByID(obj.ToString());
        if (info == null)
            return "";

        return info.SoldierName;

    }
    protected void gvTrasferStat_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // Display the company name in italics.
            //int count = TransferSoldier.NeedAcceptedCount(gvTrasferStat.DataKeys[e.Row.RowIndex].Value.ToString());
            //e.Row.Cells[2].Text = count.ToString();
            //LinkButton btn = e.Row.Cells[3].FindControl("btnAccept") as LinkButton;
            //btn.Visible = count == 0 ? false : true;

            Label ID = (Label)e.Row.FindControl("ID");
            ID.Text = (gvTrasferStat.PageIndex * gvTrasferStat.PageSize + e.Row.RowIndex + 1).ToString();
            ////当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
        }


    }

}
